package tianwang.utils.stanford;

import java.net.URL;

import edu.stanford.nlp.parser.lexparser.LexicalizedParser;
import edu.stanford.nlp.process.DocumentPreprocessor;
import edu.stanford.nlp.trees.PennTreebankLanguagePack;
import edu.stanford.nlp.trees.TreebankLanguagePack;

public class StanfordUtils {

	private static LexicalizedParser lp = null;
	private static TreebankLanguagePack tlp = null;
	private static DocumentPreprocessor dp = null;
	
	public static LexicalizedParser getLexicalizedParser(){
		if ( lp == null ){
			URL url = StanfordUtils.class.getResource("englishPCFG.ser.gz");
			lp = new LexicalizedParser(url.getPath());
			lp.setOptionFlags("-maxLength", "150", "-retainTmpSubcategories");				
		}
		return lp;
	}
	
	public static TreebankLanguagePack getTreebankLanguagePack(){
		if ( tlp == null){
			tlp = new PennTreebankLanguagePack();
		}
		return tlp;
	}
	
	public static DocumentPreprocessor getDocumentPreprocessor(){
		if ( dp == null){
			dp = new DocumentPreprocessor();
		}
		return dp;
	}
}
